
const data = {
	name:'nick',
	age: 21
}

let value = data.name

// data.name = 'ddd'
// console.log(data.name)

for(let key in data) {

	Object.defineProperty(data, key, {
		get: function() {
			console.log('读');
			return value
		},
		set: function(newVal) {
			console.log('读');
			return value
		}
	})
}
console.log(data.age)

function defineReactive(data, key, value) {
	Object.defineProperty(data, key, {
		get() {
			return value
		},
		set(newVal) {
			value = newVal
		}
	})
}

